Skip to content

667-deleteAll outbox 스케줄러 추가 - #668

Merged
ByunDohwi merged 1 commit into
developfrom
667-outbox-테이블-데이터-삭제-스케줄러-개발
May 19, 2026

Hidden character warning

The head ref may contain hidden characters: "667-outbox-\ud14c\uc774\ube14-\ub370\uc774\ud130-\uc0ad\uc81c-\uc2a4\ucf00\uc904\ub7ec-\uac1c\ubc1c"
Merged

ByunDohwi merged 1 commit into
developfrom
667-outbox-테이블-데이터-삭제-스케줄러-개발

Conversation

@ByunDohwi

@ByunDohwi ByunDohwi commented May 19, 2026 •

Copy link
Copy Markdown
Member

매일 23:59분 오늘 발행되었던 알림 이벤트를 outbox 테이블에서 삭제하는 스케줄러를 추가하였습니다.

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능
    • Outbox 데이터 자동 정리 기능이 추가되었습니다. 매일 밤 11시 59분(Asia/Seoul 기준)에 축적된 Outbox 데이터가 자동으로 삭제됩니다.

@ByunDohwi ByunDohwi self-assigned this May 19, 2026
@ByunDohwi ByunDohwi linked an issue May 19, 2026 that may be closed by this pull request
1 task done
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown

Walkthrough

이 PR은 아웃박스 데이터를 정기적으로 삭제하기 위한 기능을 구현합니다. 삭제 포트 계약을 정의하고 어댑터에서 구현한 후, 매일 자정 직전(23:59)에 실행되는 스케줄된 작업으로 통합합니다.

Changes

아웃박스 삭제 기능 추가

Layer / File(s) Summary
Outbox deletion port and adapter
src/main/kotlin/dsm/pick2024/domain/outbox/port/out/DeleteOutboxPort.kt, src/main/kotlin/dsm/pick2024/domain/outbox/persistence/OutboxAdapter.kt, src/main/kotlin/dsm/pick2024/domain/outbox/port/out/OutboxPort.kt
DeleteOutboxPort 인터페이스를 정의하고 OutboxAdapter에서 deleteAll() 메서드로 구현합니다. OutboxPort는 기존 SaveOutboxPort와 함께 새로운 DeleteOutboxPort를 확장합니다.
Scheduled cleanup task integration
src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt
DeleteOutboxPort 의존성을 주입받고 매일 23:59(Seoul)에 실행되는 cleanOutbox() 스케줄된 메서드를 추가합니다.

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • DSM-PICK/PiCK_CORE_SERVER#388: 동일한 패턴으로 새로운 Delete*Port 계약과 deleteAll() 어댑터 구현을 추가하고 ScheduleService의 스케줄된 작업에서 호출하는 구조입니다.

Suggested labels

기능 개발

Suggested reviewers

  • 1210thatman

Poem

🐰 아웃박스를 정성들여 비워내고,
매일 밤 자정에 깨끗이 정리하네.
포트 계약 맞춰서 어댑터 심어두니,
스케줄의 손길로 데이터가 사라진다!
작고 우아한 변경, Pick의 마음으로 ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Pull request 제목이 주요 변경 사항을 명확하게 요약하고 있습니다. 'outbox deleteAll 스케줄러 추가'라는 핵심 기능이 잘 드러나 있습니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 667-outbox-테이블-데이터-삭제-스케줄러-개발

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt`:
- Around line 89-92: The scheduled cleanOutbox() currently calls
deleteOutboxPort.deleteAll(), which risks removing unpublished/undelivered
events; change it to delete only events that are published and older than a
retention cutoff (e.g. compute cutoff =
LocalDateTime.now(ZoneId.of("Asia/Seoul")).minusDays(retentionDays)) and call a
new port method such as deletePublishedBefore(cutoff) (or add a
filterPublishedAndBefore(cutoff) to DeleteOutboxPort); update the
ScheduleService.cleanOutbox() to compute the cutoff and call that port method,
and implement the corresponding adapter/query to delete only records where
published=true (or publishedAt != null) AND publishedAt < cutoff.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0cac9717-5971-438a-a578-421fa146974f

📥 Commits

Reviewing files that changed from the base of the PR and between b9faa08 and 51730bb.

📒 Files selected for processing (4)
  • src/main/kotlin/dsm/pick2024/domain/outbox/persistence/OutboxAdapter.kt
  • src/main/kotlin/dsm/pick2024/domain/outbox/port/out/DeleteOutboxPort.kt
  • src/main/kotlin/dsm/pick2024/domain/outbox/port/out/OutboxPort.kt
  • src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt

Comment on lines +89 to +92
@Scheduled(cron = "0 59 23 * * ?", zone = "Asia/Seoul")
fun cleanOutbox() {
deleteOutboxPort.deleteAll()
}

@coderabbitai coderabbitai Bot May 19, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

전체 삭제 스케줄은 미처리 outbox 이벤트 유실 위험이 큽니다.

Line 91에서 매일 deleteAll()을 호출하면 아직 발행되지 않은 레코드까지 제거될 수 있습니다. 정리 대상은 최소한 발행 완료 + 보관기간 경과 조건으로 제한해야 합니다.

수정 방향 예시
 `@Scheduled`(cron = "0 59 23 * * ?", zone = "Asia/Seoul")
 fun cleanOutbox() {
-    deleteOutboxPort.deleteAll()
+    deleteOutboxPort.deletePublishedBefore(
+        cutoff = LocalDateTime.now(ZoneId.of("Asia/Seoul")).minusDays(1)
+    )
 }
// 포트/어댑터 측 추가 예시 (선택)
interface DeleteOutboxPort {
    fun deletePublishedBefore(cutoff: LocalDateTime): Long
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt`
around lines 89 - 92, The scheduled cleanOutbox() currently calls
deleteOutboxPort.deleteAll(), which risks removing unpublished/undelivered
events; change it to delete only events that are published and older than a
retention cutoff (e.g. compute cutoff =
LocalDateTime.now(ZoneId.of("Asia/Seoul")).minusDays(retentionDays)) and call a
new port method such as deletePublishedBefore(cutoff) (or add a
filterPublishedAndBefore(cutoff) to DeleteOutboxPort); update the
ScheduleService.cleanOutbox() to compute the cutoff and call that port method,
and implement the corresponding adapter/query to delete only records where
published=true (or publishedAt != null) AND publishedAt < cutoff.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 스케줄은 서비스 정책을 고려한 의도적인 동작입니다. 서비스는 20:30 이후에는 신규 이벤트가 생성되지 않으며, 날짜가 지난 이벤트가 뒤늦게 전송될 경우 오히려 사용자 혼선을 유발할 가능성이 더 크다고 판단했습니다.

따라서 outbox 데이터는 매일 종료 시점에 전체 정리하도록 구현했으며, 미전송 이벤트가 일부 제거될 가능성은 서비스 정책상 허용 가능한 trade-off로 보고 있습니다.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ByunDohwi, 설명 감사합니다. 서비스 정책상 20:30 이후 신규 이벤트가 생성되지 않으며, 날짜 경과 이벤트의 지연 전송이 오히려 사용자 혼선을 유발할 수 있다는 맥락을 이해했습니다. 해당 trade-off를 명시적으로 판단하신 것이므로 기존 구현 방식을 유지하는 것이 합리적입니다. 지적을 철회하겠습니다.

🐇 ~(=^‥^)/


✏️ Learnings added
Learnt from: ByunDohwi
Repo: DSM-PICK/PiCK_CORE_SERVER PR: 668
File: src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt:89-92
Timestamp: 2026-05-19T05:13:17.851Z
Learning: In `dsm/pick2024` (PiCK_CORE_SERVER), the `cleanOutbox()` scheduler in `src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt` intentionally calls `deleteOutboxPort.deleteAll()` (full deletion) at 23:59 every day. This is by design: the service generates no new outbox events after 20:30, and late delivery of stale events is considered more harmful (user confusion) than losing undelivered records. Deleting undelivered events at end-of-day is an explicitly accepted trade-off per service policy.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@ByunDohwi
ByunDohwi merged commit f58fa72 into develop May 19, 2026
1 check passed
@ByunDohwi
ByunDohwi deleted the 667-outbox-테이블-데이터-삭제-스케줄러-개발 branch May 19, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

outbox 테이블 데이터 삭제 스케줄러 개발

2 participants